<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );

$userid = aac ( 'user' )->isLogin ();

$articleid = intval ( $_GET ['articleid'] );

$strArticle = $new ['article']->find ( 'article', array (
    'articleid' => $articleid
) );

//普通成员不允许删除内容
if($TS_SITE['isallowdelete'] && $TS_USER ['isadmin'] == 0) tsNotice('系统不允许成员删除内容，请联系管理员删除！');
if ($strArticle ['addtime'] < strtotime('-7 day') && $TS_USER ['isadmin'] == 0) {
    tsNotice('超过一周，不允许删除，如有需要请给微澜图书馆公众号后台留言');
}
if ($strArticle ['userid']!=$TS_USER ['userid'] && $TS_USER ['isadmin'] == 0) {
    tsNotice('没有操作权限');
}


if ($strArticle ['userid'] == $userid || $TS_USER ['isadmin'] == 1) {
    $new ['article']->delete ( 'article', array (
        'articleid' => $articleid
    ) );
    $new ['article']->delete ( 'article_comment', array (
        'articleid' => $articleid
    ) );
    $new ['article']->delete ( 'article_recommend', array (
        'articleid' => $articleid
    ) );
}

// 统计小组下文档数并更新
$count_article = $new ['article']->findCount ( 'article', array (
    'groupid' => $groupid
) );
$new ['article']->update ( 'group', array (
    'groupid' => $groupid
), array (
    'count_article' => $count_article,
    'uptime' => time ()
) );


tsNotice('删除成功','点击返回文档首页',tsUrl ( 'article' ));